<template>
  <footer class="footer">
    <span class="todo-count">剩余<strong>{{leftCount}}</strong></span>
    <ul class="filters">
      <li>
        <a :class="{selected:type==='all'}" @click="$emit('clickType','all')"  href="javascript:;" >全部</a>
      </li>
      <li>
        <a :class="{selected:type==='no'}" @click="$emit('clickType','no')" href="javascript:;">未完成</a>
      </li>
      <li>
        <a :class="{selected:type==='yes'}" @click="$emit('clickType','yes')" href="javascript:;" >已完成</a>
      </li>
    </ul>
    <button class="clear-completed" @click="clear" v-show="isShowClear">清除已完成</button>
  </footer>
</template>

<script>
export default {
  props:{
    list:{
      type:Array,
      required:true
    },
    type:String
  },
  computed: {
    leftCount() {
       //统计未完成的数量
      return this.list.filter(item=>item.isDone===false).length
    },
    isShowClear() {
      return this.list.some(item=>item.isDone)
    }
  },
  methods: {
    clear() {
      this.$emit("clear")
    }
  }

}
</script>